<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html><% request.setAttribute("ctx", request.getContextPath());%>
<html lang="zh-CN"><%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>登录</title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  <%--<link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.css" rel="stylesheet">--%>
  <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
</head>
<body>
<shiro:notAuthenticated>
<div class="well" style="width:400px; margin: 40px auto;">
  <c:if test="${!(empty loginError)}">
    <div class="alert alert-danger alert-dismissible" role="alert">
      <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <strong>登录失败!</strong> 错误：${loginError}
    </div>
  </c:if>
  <form method="post" id="m_form" role="form" onsubmit="return doSubmit()">
    <div class="form-group">
      <label for="m_username">登录名</label>
      <input type="text" name="username" class="form-control" id="m_username" placeholder="登录名" check-type="required"
             value="" >
    </div>
    <div class="form-group">
      <label for="m_password">密码</label>
      <input type="password" name="password" class="form-control" id="m_password" check-type="required" placeholder="密码">
    </div>

    <button type="submit" class="btn btn-primary">登录</button>
  </form>
</div>
</shiro:notAuthenticated>
<shiro:authenticated>
  <div class="well" style="width:400px; margin: 40px auto;">
    <h1>Welcome <%=session.getAttribute("nickname") %></h1>
    <div>
      <p>
        <a href="${ctx}/logout" class="btn btn-primary">登出</a>
      </p>
    </div>
  </div>
</shiro:authenticated>
<script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="${ctx}/static/js/bootstrap3-validation.js"></script>
<script>
  function doSubmit() {
    return $('#m_form').valid();
  }
  $(function() {
    $('form').validation();
  })
</script>
</body>
</html>
